Linear equation over a ring